#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
	long int n, i = 0, e, f = 1;
	char a, b[10];
	clrscr();

	printf("\n\n\t\tPress ESC to Exit");
	printf("\n\n\t\tPlease Enter the Numeric Value:");
	while(1)
	{
		window(49, 5+i, 80, 25);
		a = getche();

		if(a == 27)
		{
			break;
		}
		if(a >= 48 && a <= 57)
		{
			printf("                               ");
			b[i] = a;
			i++;
		}
		else
		{
			printf("\n\n\t\tThis is not a valid No.");
		}
		if(i == 1)
		{
			break;
		}
	}

	n = atol(b);

	printf("\n\n\t\tYour Entered Numeric Value is: %d\n\n\tPress any key to continue ", n);
	getch();

	for(i = n; i >= 1; i--)
	{
		e = f;
		f = f * i;
		printf("\n\n\t\t%ld * %ld = %ld", i, e, f);
	}
	printf("\n\n\t\t   Factorial: = %ld", f);
	getch();
}